//package com.kin.bitmapcatching;
//
//import java.io.File;
//import java.lang.ref.WeakReference;
//import java.lang.reflect.Array;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Date;
//
//import com.kin.bitmapcatching.DisplayBitmap.AsyncDrawable;
//import com.kin.bitmapcatching.DisplayBitmap.BitmapWorkerTask;
//
//import android.app.Activity;
//import android.app.ActivityManager;
//import android.content.ActivityNotFoundException;
//import android.content.Context;
//import android.content.Intent;
//import android.content.res.Resources;
//import android.database.Cursor;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.graphics.drawable.BitmapDrawable;
//import android.graphics.drawable.Drawable;
//import android.net.Uri;
//import android.os.AsyncTask;
//import android.os.Bundle;
//import android.os.Environment;
//import android.provider.MediaStore;
//import android.provider.MediaStore.Images.ImageColumns;
//import android.support.v4.util.LruCache;
//import android.util.Log;
//import android.view.View;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.ListView;
//import android.widget.Toast;
//
//public class CatchingBitmapActivity extends Activity {
//	private ArrayList<String> mListImage;
//	private ListImageAdapter adapter;
//	private ListView mListView;
//	
//	
//	String[] mListURLImage = {
//			"http://a3.twimg.com/profile_images/670625317/aam-logo-v3-twitter.png",
//            "http://a3.twimg.com/profile_images/740897825/AndroidCast-350_normal.png",
//            "http://a3.twimg.com/profile_images/121630227/Droid_normal.jpg",
//            "http://a1.twimg.com/profile_images/957149154/twitterhalf_normal.jpg",
//            "http://a1.twimg.com/profile_images/97470808/icon_normal.png",
//            "http://a3.twimg.com/profile_images/511790713/AG.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
//            "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
//            "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
//            "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
//            "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
//            "http://a1.twimg.com/profile_images/655119538/andbook.png",
//            "http://a3.twimg.com/profile_images/768060227/ap4u_normal.jpg",
//            "http://a1.twimg.com/profile_images/74724754/android_logo_normal.png",
//            "http://a3.twimg.com/profile_images/681537837/SmallAvatarx150_normal.png",
//            "http://a1.twimg.com/profile_images/63737974/2008-11-06_1637_normal.png",
//            "http://a3.twimg.com/profile_images/548410609/icon_8_73.png",
//            "http://a1.twimg.com/profile_images/612232882/nexusoneavatar_normal.jpg",
//            "http://a1.twimg.com/profile_images/213722080/Bugdroid-phone_normal.png",
//            "http://a1.twimg.com/profile_images/645523828/OT_icon_090918_android_normal.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet.png",
//            "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
//            "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
//            "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
//            "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
//            "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
//            "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon_normal.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
//            "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300.jpg",
//            "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
//            "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
//            "http://a3.twimg.com/profile_images/121630227/Droid.jpg",
//            "http://a1.twimg.com/profile_images/957149154/twitterhalf_normal.jpg",
//            "http://a1.twimg.com/profile_images/97470808/icon_normal.png",
//            "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man.png",
//            "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
//            "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
//            "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon_normal.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet.png",
//            "http://a3.twimg.com/profile_images/670625317/aam-logo-v3-twitter_normal.png",
//            "http://a3.twimg.com/profile_images/740897825/AndroidCast-350_normal.png",
//            "http://a3.twimg.com/profile_images/121630227/Droid_normal.jpg",
//            "http://a1.twimg.com/profile_images/957149154/twitterhalf_normal.jpg",
//            "http://a1.twimg.com/profile_images/97470808/icon.png",
//            "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
//            "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
//            "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
//            "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
//            "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
//            "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
//            "http://a3.twimg.com/profile_images/768060227/ap4u_normal.jpg",
//            "http://a1.twimg.com/profile_images/74724754/android_logo.png",
//            "http://a3.twimg.com/profile_images/681537837/SmallAvatarx150_normal.png",
//            "http://a1.twimg.com/profile_images/63737974/2008-11-06_1637_normal.png",
//            "http://a3.twimg.com/profile_images/548410609/icon_8_73_normal.png",
//            "http://a1.twimg.com/profile_images/612232882/nexusoneavatar_normal.jpg",
//            "http://a1.twimg.com/profile_images/213722080/Bugdroid-phone_normal.png",
//            "http://a1.twimg.com/profile_images/645523828/OT_icon_090918_android.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
//            "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
//            "http://a1.twimg.com/profile_images/655119538/andbook.png",
//            "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
//            "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
//            "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
//            "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
//            "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
//            "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
//            "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
//            "http://a3.twimg.com/profile_images/121630227/Droid_normal.jpg",
//            "http://a1.twimg.com/profile_images/957149154/twitterhalf.jpg",
//            "http://a1.twimg.com/profile_images/97470808/icon_normal.png",
//            "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
//            "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
//            "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
//            "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
//            "http://a1.twimg.com/profile_images/349012784/android_logo_small.jpg",
//            "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon_normal.png",
//            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
//            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png"
//	};
//	
//	
//	
//    /** Called when the activity is first created. */
//    @Override
//    public void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.main);
//        mPlaceHolderBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
//        mListView = (ListView) findViewById(R.id.listImage);
//        
//        mListImage = new ArrayList<String>();
//        GetAllImageTask task = new GetAllImageTask(this);
//        task.execute();
//    }
//    
//    private Uri fileUri;
//    public static final int MEDIA_TYPE_IMAGE = 1;
//    public static final int MEDIA_TYPE_VIDEO = 2;
//    private static int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
//    private static int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 200;
//    private static int PICK_IMAGE_ACTIVITY_REQUEST_CODE = 300;
//    private Bitmap mPlaceHolderBitmap;
//    
//    
//    /** Create a file Uri for saving an image or video */
//    private static Uri getOutputMediaFileUri(int type,Context context){
//          return Uri.fromFile(getOutputMediaFile(type,context));
//    }
//    
//    /** Create a File for saving an image or video */
//    private static File getOutputMediaFile(int type,Context context){
//        // To be safe, you should check that the SDCard is mounted
//        // using Environment.getExternalStorageState() before doing this.
//
//        File mediaStorageDir = new File("sdcard/data/" +  
//        		context.getPackageName()+ "/files/" );
//        // This location works best if you want the created images to be shared
//        // between applications and persist after your app has been uninstalled.
//
//        // Create the storage directory if it does not exist
//        if (! mediaStorageDir.exists()){
//            if (! mediaStorageDir.mkdirs()){
//                Log.d("MyCameraApp", "failed to create directory");
//                return null;
//            }
//        }
//
//        // Create a media file name
//        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
//        File mediaFile;
//        if (type == MEDIA_TYPE_IMAGE){
//            mediaFile = new File(mediaStorageDir.getPath() + File.separator +
//            "IMG_"
////            		+timeStamp 
//            + ".jpg");
//        } else if(type == MEDIA_TYPE_VIDEO) {
//            mediaFile = new File(mediaStorageDir.getPath() + File.separator +
//            "VID_"
////            		+ timeStamp 
//            		+ ".mp4");
//        } else {
//            return null;
//        }
//
//        return mediaFile;
//    }
//
//    
//    public void captureBitmap(View v)
//    {
//    	// create Intent to take a picture and return control to the calling application
//        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
//
//        fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE,this); // create a file to save the image
//        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
//
//        // start the image capture Intent
//        startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
//    }
//    
//    public void chooseBitmap(View v)
//    {
//		if (Environment.getExternalStorageState()
//				.equalsIgnoreCase(android.os.Environment.MEDIA_MOUNTED))
//		{
//			try
//			{
//				Intent pickPhotoIntent = new Intent(Intent.ACTION_PICK,
//						MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//				startActivityForResult(pickPhotoIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
//						PICK_IMAGE_ACTIVITY_REQUEST_CODE);
//			}
//			catch (ActivityNotFoundException ane)
//			{
//				Log.e("Choose bitmap", ">>> ERROR when calling pick photo app: " + ane.toString());
//			}
//		}
//    }
//        
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
//            if (resultCode == RESULT_OK) {
//                // Image captured and saved to fileUri specified in the Intent
//            	fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE, this);
//            	File fileName = new File(fileUri.getPath());
//                Toast.makeText(this, "Image saved to:\n" +
//                         fileName , Toast.LENGTH_LONG).show();
//                
//                BitmapFactory.Options options = new BitmapFactory.Options();
//                options.inJustDecodeBounds = true;
//                BitmapFactory.decodeFile(fileUri.getPath(), options);
//                int imageHeight = options.outHeight;
//                int imageWidth = options.outWidth;
////                String imageType = options.outMimeType;
//                
//
////            	EditText imgInfo = (EditText) findViewById(R.id.imgInfo);
////            	imgInfo.setText("imageHeight = " + imageHeight +
////            			" imageWidth = " + imageWidth);
//            	
////            	BitmapWorkerTask taskDecodeFile = new BitmapWorkerTask(imgView);
////            	taskDecodeFile.execute(fileUri.getPath());
//            	ImageView imgView = (ImageView) findViewById(R.id.imgCapture);
////            	loadBitmap(fileUri.getPath(), imgView);
//            } else if (resultCode == RESULT_CANCELED) {
//                // User cancelled the image capture
//            } else {
//                // Image capture failed, advise user
//            }
//        }
//
//        else if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) {
//            if (resultCode == RESULT_OK) {
//                // Video captured and saved to fileUri specified in the Intent
//                Toast.makeText(this, "Video saved to:\n" +
//                         data.getData(), Toast.LENGTH_LONG).show();
//            } else if (resultCode == RESULT_CANCELED) {
//                // User cancelled the video capture
//            } else {
//                // Video capture failed, advise user
//            }
//        }
//        else if (requestCode == PICK_IMAGE_ACTIVITY_REQUEST_CODE)
//        {
//        	if (resultCode == RESULT_OK)
//        	{
//        		if (data !=null)
//        		{
//        			Uri imageUri = data.getData();
//        			if (imageUri !=null)
//        			{
//        				Log.d("Image picked", imageUri.getPath());
//        				Cursor cursor = this.getContentResolver().query(imageUri, 
//        						new String[] {ImageColumns.DATA}, 
//        						null, 
//        						null, 
//        						null);
//        				if (cursor!=null && cursor.moveToFirst())
//        				{
//        					String mImageName = cursor.getString(0);
//        					Log.d("Image Name", mImageName);
//        	            	ImageView imgView = (ImageView) findViewById(R.id.imgCapture);
////        	            	loadBitmap(mImageName, imgView);
//        				}
//        			}
//        		}
//        	}
//        }
//        
//    }
//    
//    
//    private class GetAllImageTask extends AsyncTask<Void, Void, Void>
//    {
//    	private Context mContext;
//    	public GetAllImageTask(Context context)
//    	{
//    		mContext = context;
//    	}
//		@Override
//		protected Void doInBackground(Void... params)
//		{
//			// TODO Auto-generated method stub
////			Cursor cursor = mContext.getContentResolver().query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, 
////					new String[] {ImageColumns.DATA}, 
////					null, 
////					null, 
////					null);
////			if (cursor!=null)
////			{
////				while (cursor.moveToNext())
////				{
////					String mImageName = cursor.getString(0);
////					Log.d("Image Name", mImageName);
////					mListImage.add(mImageName);
//////					if (mListImage.size()>=300)
//////						return null;
////				}
////			}
//			for (int i=0;i<mListURLImage.length;i++)
//			{
//				mListImage.add(mListURLImage[i]);
//			}
//			return null;
//		}
//		@Override
//		protected void onProgressUpdate(Void... values)
//		{
//			// TODO Auto-generated method stub
//			super.onProgressUpdate(values);
//		}
//		@Override
//		protected void onPostExecute(Void result)
//		{
//			// TODO Auto-generated method stub
//	        adapter = new ListImageAdapter(CatchingBitmapActivity.this, mListImage);
//	        mListView.setAdapter(adapter);
//	        adapter.notifyDataSetChanged();
//			super.onPostExecute(result);
//		}
//    }
//    
//    
//
//}